package com.cmbchina.entity;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class Currency {
    private String currency;

    private static final Set<String> VALID_CURRENCY_SET = new HashSet<String>(){{
        add("CNY"); add("USD"); add("EUR"); add("JPY"); add("HKD");
    }};

    public Currency(String currency){
        setCurrency(currency);
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        if(Objects.isNull(currency)){
            throw new IllegalArgumentException("currency cannot be null");
        }

        if(!VALID_CURRENCY_SET.contains(currency.toUpperCase())){
            throw new IllegalArgumentException("invalid currency or not support for now");
        }
        this.currency = currency;
    }

}
